package net.orange.framework.logic;

import java.util.Collection;

import net.orange.architecture.db.Condition;
import net.orange.architecture.db.Conditions;
import net.orange.architecture.db.ICacheDao;
import net.orange.architecture.process.BaseProcess;
import net.orange.framework.model.Group;
import net.orange.framework.model.Resource;

/**
 * The resource business logical process object which implement the
 * IResourceProcess interface.
 */
public class ResourceProcess extends BaseProcess implements IResourceProcess {
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * net.orange.framework.resource.process.IResourceProcess#findByKey(java
	 * .lang.String)
	 */
	public Resource findByKey(String key) throws Exception {
		return (Resource) ((ICacheDao) dao).findByKey(key);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * net.orange.framework.logic.IResourceProcess#findByGroup(net.orange.framework
	 * .model.Group)
	 */
	public Collection findByGroup(Group group) throws Exception {
		if (group == null)
			return null;

		Conditions cnds = new Conditions();
		cnds.add(new Condition("groups.pk", group.getPk()));

		return dao.list(cnds);
	}

}